package com.wen.zxing;

import android.app.Activity;
import android.content.Intent;

import cn.wen.core.permission.Permission;
import cn.wen.core.permission.PermissionListenerAdapter;
import cn.wen.core.permission.XPermission;


/**
 * 二维码扫描工具类
 */

public class ZxingUtil {
    /**
     * 二维码扫描
     */
    public static void scan(final Activity activity, final OnScanListener onScanListener) {
        if (activity == null) {
            return;
        }
        new XPermission(activity)
                .permissions(Permission.CAMERA)
                .request(new PermissionListenerAdapter() {
                    @Override
                    public void onSucceed() {
                        CaptureActivity.mOnScanListener = onScanListener;
                        Intent intent = new Intent(activity, CaptureActivity.class);
                        activity.startActivity(intent);
                    }
                });

    }
}
